<template>
	<div>
		<el-card shadow="never" class="card" v-loading="loading">
			<div class="card_content">
				<el-form label-position="left" :size="formSize" ref="form" :model="form" class="config_form" :rules="rules" label-width="120px" >
					<el-tabs v-model="activeName">
						<el-tab-pane label="基本信息" name="基本信息">
							<div class="col_wrap">
								<div  class="col_wrap_item">
									<el-form-item prop="site_logo">
										<template slot="label">
											<span>系统Logo </span>
											<el-tooltip content="设置系统侧栏顶部显示的图片" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<ImagesUpload :size="formSize"   fileType="image" :image.sync="form.site_logo"></ImagesUpload>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="site_title">
										<template slot="label">
											<span>系统名称 </span>
											<el-tooltip content="设置本管理系统的名称" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  v-model="form.site_title" autoComplete="off" clearable  placeholder="请输入系统名称"></el-input>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="site_subtitle">
										<template slot="label">
											<span>副标题 </span>
											<el-tooltip content="设置前端站点的描述信息，后端系统未使用此设置；" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  v-model="form.site_subtitle" autoComplete="off" clearable  placeholder="请输入副标题"></el-input>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="site_note">
										<template slot="label">
											<span>特色 </span>
											<el-tooltip content="系统登录界面中显示的系统特色，以回车分割，最多5句话" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  type="textarea" autoComplete="off" v-model="form.site_note"  :autosize="{ minRows: 2, maxRows: 4}" clearable placeholder="请输入特色"/>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="copyright">
										<template slot="label">
											<span>系统版权 </span>
											<el-tooltip content="设置后端系统登录页面中的授权声明信息" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  v-model="form.copyright" autoComplete="off" clearable  placeholder="请输入系统版权"></el-input>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="show_default_menu">
										<template slot="label">
											<span>内置菜单 </span>
											<el-tooltip content="是否在菜单管理表格中显示内置菜单项" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-radio-group v-model="form.show_default_menu">
											<el-radio :label="'1'">显示</el-radio>
											<el-radio :label="'0'">隐藏</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="show_statisic">
										<template slot="label">
											<span>显示统计 </span>
											<el-tooltip content="首页是否显示统计数据" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-radio-group v-model="form.show_statisic">
											<el-radio :label="'1'">显示</el-radio>
											<el-radio :label="'2'">隐藏</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="show_menu">
										<template slot="label">
											<span>首页启动 </span>
											<el-tooltip content="设置首页是否显示启动图标" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-radio-group v-model="form.show_menu">
											<el-radio :label="'1'">显示</el-radio>
											<el-radio :label="'2'">隐藏</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="show_chart">
										<template slot="label">
											<span>显示图表 </span>
											<el-tooltip content="是否在首页显示统计图表" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-radio-group v-model="form.show_chart">
											<el-radio :label="'1'">显示</el-radio>
											<el-radio :label="'2'">隐藏</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
							</div>
						</el-tab-pane>
						<el-tab-pane label="上传配置" name="上传配置">
							<div class="col_wrap">
								<div  class="col_wrap_item">
									<el-form-item prop="oss_status">
										<template slot="label">
											<span>存储位置 </span>
										</template>
										<el-radio-group v-model="form.oss_status">
											<el-radio :label="'1'">本地存储</el-radio>
											<el-radio :label="'2'">OSS存储</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' " class="col_wrap_item">
									<el-form-item prop="oss_default_type">
										<template slot="label">
											<span>OSS类型 </span>
										</template>
										<el-radio-group v-model="form.oss_default_type">
											<el-radio :label="'1'">阿里云</el-radio>
											<el-radio :label="'2'">七牛云</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '2'" class="col_wrap_item">
									<el-form-item prop="qny_oss_accessKey">
										<template slot="label">
											<span>AccessKey </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.qny_oss_accessKey"  clearable placeholder="请输入AccessKey"/>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '2'" class="col_wrap_item">
									<el-form-item prop="qny_oss_secretKey">
										<template slot="label">
											<span>SecretKey </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.qny_oss_secretKey"  clearable placeholder="请输入SecretKey"/>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '2'" class="col_wrap_item">
									<el-form-item prop="qny_oss_bucket">
										<template slot="label">
											<span>Bucket </span>
										</template>
										<el-input  v-model="form.qny_oss_bucket" autoComplete="off" clearable  placeholder="请输入Bucket"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '2'" class="col_wrap_item">
									<el-form-item prop="qny_oss_domain">
										<template slot="label">
											<span>Domain </span>
										</template>
										<el-input  v-model="form.qny_oss_domain" autoComplete="off" clearable  placeholder="请输入Domain"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '1'" class="col_wrap_item">
									<el-form-item prop="ali_oss_accessKeyId">
										<template slot="label">
											<span>AccessKeyId </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.ali_oss_accessKeyId"  clearable placeholder="请输入AccessKeyId"/>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '1'" class="col_wrap_item">
									<el-form-item prop="ali_oss_accessKeySecret">
										<template slot="label">
											<span>AccessKeySecret </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.ali_oss_accessKeySecret"  clearable placeholder="请输入AccessKeySecret"/>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '1'" class="col_wrap_item">
									<el-form-item prop="ali_oss_endpoint">
										<template slot="label">
											<span>Endpoint </span>
										</template>
										<el-input  v-model="form.ali_oss_endpoint" autoComplete="off" clearable  placeholder="请输入Endpoint"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.oss_status == '2' && form.oss_default_type == '1'" class="col_wrap_item">
									<el-form-item prop="ali_oss_bucket">
										<template slot="label">
											<span>Bucket </span>
										</template>
										<el-input  v-model="form.ali_oss_bucket" autoComplete="off" clearable  placeholder="请输入Bucket"></el-input>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="filesize">
										<template slot="label">
											<span>上传最大值 </span>
											<el-tooltip content="设置上传文件大小的最大值单位（M）" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  v-model="form.filesize" autoComplete="off" clearable  placeholder="请输入上传最大值"></el-input>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="filetype">
										<template slot="label">
											<span>文件类型 </span>
											<el-tooltip content="设置允许上传的文件类型" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  v-model="form.filetype" autoComplete="off" clearable  placeholder="请输入文件类型"></el-input>
									</el-form-item>
								</div>
							</div>
						</el-tab-pane>
						<el-tab-pane label="短信配置" name="短信配置">
							<div class="col_wrap">
								<div  class="col_wrap_item">
									<el-form-item prop="sms_type">
										<template slot="label">
											<span>短信网关 </span>
										</template>
										<el-radio-group v-model="form.sms_type">
											<el-radio :label="'Test'">仅测试</el-radio>
											<el-radio :label="'Ali'">阿里</el-radio>
											<el-radio :label="'Juhe'">聚合</el-radio>
											<el-radio :label="'Jisu'">极速</el-radio>
											<el-radio :label="'Cryun'">创瑞</el-radio>
										</el-radio-group>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Ali'" class="col_wrap_item">
									<el-form-item prop="ali_sms_accessKeyId">
										<template slot="label">
											<span>AccessKeyId </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.ali_sms_accessKeyId"  clearable placeholder="请输入AccessKeyId"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Ali'" class="col_wrap_item">
									<el-form-item prop="ali_sms_accessKeySecret">
										<template slot="label">
											<span>AccessKeySecret </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.ali_sms_accessKeySecret"  clearable placeholder="请输入AccessKeySecret"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Ali'" class="col_wrap_item">
									<el-form-item prop="ali_sms_signname">
										<template slot="label">
											<span>Sign </span>
										</template>
										<el-input  v-model="form.ali_sms_signname" autoComplete="off" clearable  placeholder="请输入Sign"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Ali'" class="col_wrap_item">
									<el-form-item prop="ali_sms_tempCode">
										<template slot="label">
											<span>TemplateCode </span>
										</template>
										<el-input  v-model="form.ali_sms_tempCode" autoComplete="off" clearable  placeholder="请输入TemplateCode"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Juhe'" class="col_wrap_item">
									<el-form-item prop="juhe_sms_key">
										<template slot="label">
											<span>SmsKey </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.juhe_sms_key"  clearable placeholder="请输入SmsKey"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Juhe'" class="col_wrap_item">
									<el-form-item prop="juhe_sms_tempCode">
										<template slot="label">
											<span>TempCode </span>
										</template>
										<el-input  v-model="form.juhe_sms_tempCode" autoComplete="off" clearable  placeholder="请输入TempCode"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Jisu'" class="col_wrap_item">
									<el-form-item prop="jisu_sms_key">
										<template slot="label">
											<span>SmsKey </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.jisu_sms_key"  clearable placeholder="请输入SmsKey"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Jisu'" class="col_wrap_item">
									<el-form-item prop="jisu_sms_tempCode">
										<template slot="label">
											<span>TemplateCode </span>
										</template>
										<el-input  v-model="form.jisu_sms_tempCode" autoComplete="off" clearable  placeholder="请输入TemplateCode"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Cryun'" class="col_wrap_item">
									<el-form-item prop="cryun_accesskey">
										<template slot="label">
											<span>AccessKey </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.cryun_accesskey"  clearable placeholder="请输入AccessKey"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Cryun'" class="col_wrap_item">
									<el-form-item prop="cryun_secret">
										<template slot="label">
											<span>Secret </span>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.cryun_secret"  clearable placeholder="请输入Secret"/>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Cryun'" class="col_wrap_item">
									<el-form-item prop="cryun_templateCode">
										<template slot="label">
											<span>TemplateCode </span>
										</template>
										<el-input  v-model="form.cryun_templateCode" autoComplete="off" clearable  placeholder="请输入TemplateCode"></el-input>
									</el-form-item>
								</div>
								<div v-if="form.sms_type == 'Cryun'" class="col_wrap_item">
									<el-form-item prop="cryun_sign">
										<template slot="label">
											<span>Sign </span>
										</template>
										<el-input  v-model="form.cryun_sign" autoComplete="off" clearable  placeholder="请输入Sign"></el-input>
									</el-form-item>
								</div>
							</div>
						</el-tab-pane>
						<el-tab-pane label="代码生成" name="代码生成">
							<div class="col_wrap">
								<div  class="col_wrap_item">
									<el-form-item prop="appid">
										<template slot="label">
											<span>APPID </span>
											<el-tooltip content="请联系客服购买授权(QQ:11905091)" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.appid"  clearable placeholder="请输入APPID"/>
									</el-form-item>
								</div>
								<div  class="col_wrap_item">
									<el-form-item prop="secrect">
										<template slot="label">
											<span>SECRECT </span>
											<el-tooltip content="请联系客服购买授权(QQ:11905091)" placement="top-start">
												<i class="el-icon-warning-outline"></i>
											</el-tooltip>
										</template>
										<el-input  show-password autoComplete="off" v-model="form.secrect"  clearable placeholder="请输入SECRECT"/>
									</el-form-item>
								</div>
							</div>
						</el-tab-pane>
					</el-tabs>
				</el-form>
			</div>
			<div style="display:flex;justify-content: center;width: 100%;">
				<el-button size="small" type="primary" @click="submit">保存设置</el-button>
			</div>
		</el-card>
	</div>
</template>
<script>
import { index  ,getInfo} from '@/api/admin/admin/config'
import ImagesUpload from '@/components/common/ImagesUpload.vue'
import mixinVexTable from "@/mixin/vxeTable"
export default {
	name:'admin_configindex',
	mixins: [mixinVexTable],
	components: {
		ImagesUpload,
	},
	data(){
		return {
			form: {
				appid:'',
				secrect:'',
				oss_status:'1',
				oss_default_type:'1',
				qny_oss_accessKey:'',
				qny_oss_secretKey:'',
				qny_oss_bucket:'',
				qny_oss_domain:'',
				ali_oss_accessKeyId:'',
				ali_oss_accessKeySecret:'',
				ali_oss_endpoint:'',
				ali_oss_bucket:'',
				sms_type:'Test',
				ali_sms_accessKeyId:'',
				ali_sms_accessKeySecret:'',
				ali_sms_signname:'',
				ali_sms_tempCode:'',
				juhe_sms_key:'',
				juhe_sms_tempCode:'',
				jisu_sms_key:'',
				jisu_sms_tempCode:'',
				cryun_accesskey:'',
				cryun_secret:'',
				cryun_templateCode:'',
				cryun_sign:'',
				site_logo:'',
				site_title:'',
				site_subtitle:'',
				site_note:'',
				copyright:'',
				filesize:'0',
				filetype:'',
				show_default_menu:'1',
				show_statisic:'1',
				show_menu:'1',
				show_chart:'1',
			},
			loading:false,
			show:false,
			activeName:'基本信息',
			rules: {
			}
		}
	},
	mounted(){
		getInfo().then(res => {
			if(res.status == 200){
				if(JSON.stringify(res.data) != '[]'){
				Object.assign(this.form,res.data)
				}
				this.show = true
			}
		})
	},
	methods: {
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					index(this.form).then(res => {
						this.loading = false
						if(res.status == 200){
							this.$message({message: '操作成功', type: 'success'})
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss';
</style>
